package com.wtgroup.demo.mianshi.容器;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author nisus
 * @version 0.1
 * @since 2023/6/8 16:41
 */
public class D_ArrayBlockingQueue {

    public static void main(String[] args) {
        ArrayBlockingQueue<Integer> queue = new ArrayBlockingQueue<Integer>(5);
        queue.add(1); // 用的 offer
        queue.offer(1);
        try {
            queue.put(2);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        queue.poll();
        try {
            queue.take();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

}
